"use strict"
var db = require('../db-connection');

class categoryDB {
    getAllCategory(request, respond){
        var sort_by = request.body.sort_by;

        var sql = "SELECT name FROM restaurant INNER JOIN category ON restaurant.sort_by = category.sort_by WHERE category.sort_by = ?";
        db.query(sql, [sort_by] ,function(error, result){
            if(error){
                throw error;
            }
            else{
                respond.json(result);
            }
        });
    }
}

module.exports = categoryDB;